import React from 'react';
import {withRouter} from 'react-router-dom';
export default function(Com){
     class Menu extends React.Component{
        componentDidMount(){
            //导航
            const that = this;
            $(".m-new").unbind();
            $(".m-text").unbind();
            $(".m-new").click(function(){
                if($(this).next(".text").is(":visible")){
                    $(this).next(".text").slideUp("fast");
                    $(this).removeClass("s-down");
                }else{
                    $(this).next(".text").slideDown("fast");
                    $(this).addClass("s-down");
                }
            });
            $(".m-text").click(function(){
                var me = $(this);
                $(".m-text").removeClass("s-crt");
                me.addClass("s-crt");
                let hash = location.hash.replace('#/','');
                let dataHash = me.data('hash');
                if(!me.parent('a').length ){
                    if(hash != dataHash){
                        that.props.history.push(dataHash)
                    }
                    else{
                        location.reload();
                    }
                }
    
            });
            
            $('[data-hash].s-crt').removeClass('s-crt');
            let hash = location.hash.replace('#/','');
            $(`[data-hash="${hash}"]`).addClass('s-crt');
        }
        render(){
            const {} = this.props;
            return(
                <React.Fragment>
                    <Com/>
                </React.Fragment>
             )
        }
    }
    return withRouter(Menu);
}